Revert "text: Avoid creating a PangoAttrList we don't need"
authorMatthias Clasen <mclasen@redhat.com>
Fri, 26 Jun 2020 19:27:09 +0000 (15:27 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 26 Jun 2020 19:27:17 +0000 (15:27 -0400)
This reverts commit 67c26650280ba64ff1c0318be8d848e9563ddb21.

The splicing we do here has the important side-effect
of shifting the preedit attributes to the right position.
Without it, we end up always underlining the first chars
in the entry, regardless where the preedit happens.

gtk/gtktext.c

index 2e4484c1f6aa8c9dc3e0beedee39210d3c2bdad3..67400607a94ac50596f2c9d97450f150e1116c03 100644 (file)
@@ -4354,6 +4354,8 @@ gtk_text_create_layout (GtkText  *self,
 
   tmp_attrs = gtk_css_style_get_pango_attributes (gtk_css_node_get_style (gtk_widget_get_css_node (widget)));
   tmp_attrs = _gtk_pango_attr_list_merge (tmp_attrs, priv->attrs);
+  if (!tmp_attrs)
+    tmp_attrs = pango_attr_list_new ();
 
   display_text = gtk_text_get_display_text (self, 0, -1);
 
@@ -4374,10 +4376,7 @@ gtk_text_create_layout (GtkText  *self,
       pos = g_utf8_offset_to_pointer (display_text, priv->current_pos) - display_text;
       g_string_insert (tmp_string, pos, preedit_string);
       pango_layout_set_text (layout, tmp_string->str, tmp_string->len);
-      if (tmp_attrs)
-        pango_attr_list_splice (tmp_attrs, preedit_attrs, pos, preedit_length);
-      else
-        tmp_attrs = pango_attr_list_ref (preedit_attrs);
+      pango_attr_list_splice (tmp_attrs, preedit_attrs, pos, preedit_length);
       g_string_free (tmp_string, TRUE);
     }
   else